using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class ApPymtMap : EntityTypeConfiguration<ApPymt>
    {
        public ApPymtMap()
        {
            // Primary Key
            this.HasKey(t => t.REFERENCE);

            // Properties
            this.Property(t => t.BATCH)
                .IsRequired()
                .HasMaxLength(8);

            this.Property(t => t.ID)
                .HasMaxLength(6);

            this.Property(t => t.CHECK)
                .HasMaxLength(9);

            this.Property(t => t.REFERENCE)
                .IsRequired()
                .HasMaxLength(6);

            this.Property(t => t.ENTITY)
                .IsRequired()
                .HasMaxLength(4);

            this.Property(t => t.CASHACCT)
                .IsRequired()
                .HasMaxLength(40);

            this.Property(t => t.PV)
                .IsRequired()
                .HasMaxLength(6);

            this.Property(t => t.DESCR)
                .HasMaxLength(40);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("ApPymt");
            this.Property(t => t.BATCH).HasColumnName("BATCH");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.CHECK).HasColumnName("CHECK");
            this.Property(t => t.AMOUNT).HasColumnName("AMOUNT");
            this.Property(t => t.AMOUNTDOL).HasColumnName("AMOUNTDOL");
            this.Property(t => t.DATE).HasColumnName("DATE");
            this.Property(t => t.REFERENCE).HasColumnName("REFERENCE");
            this.Property(t => t.ENTITY).HasColumnName("ENTITY");
            this.Property(t => t.CASHACCT).HasColumnName("CASHACCT");
            this.Property(t => t.VENDCUR).HasColumnName("VENDCUR");
            this.Property(t => t.CASHAMOUNT).HasColumnName("CASHAMOUNT");
            this.Property(t => t.AMOUNTACCT).HasColumnName("AMOUNTACCT");
            this.Property(t => t.CURRENCY).HasColumnName("CURRENCY");
            this.Property(t => t.PAYERTYPE).HasColumnName("PAYERTYPE");
            this.Property(t => t.PV).HasColumnName("PV");
            this.Property(t => t.DESCR).HasColumnName("DESCR");
            this.Property(t => t.CSTCTRID).HasColumnName("CSTCTRID");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");

            // Relationships
            this.HasRequired(t => t.Acct)
                .WithMany(t => t.ApPymts)
                .HasForeignKey(d => d.CASHACCT);
            this.HasRequired(t => t.Batchttl)
                .WithMany(t => t.ApPymts)
                .HasForeignKey(d => d.BATCH);
            this.HasOptional(t => t.Cstctr)
                .WithMany(t => t.ApPymts)
                .HasForeignKey(d => d.CSTCTRID);

        }
    }
}
